package com.example.algorithm.tree;

import javax.validation.constraints.NotNull;

/**
 * description
 *
 * @author Mi Dakun
 * @version 2022-1-17
 */
public class TreeNode {

    protected int number;

    public TreeNode(int number) {
        this.number = number;
    }

    public int compareTo(@NotNull TreeNode node) {
        if (node == null) {
            throw new RuntimeException("The node can't be null!");
        }
        if (number > node.number) {
            return 1;
        } else if (number == node.number) {
            return 0;
        } else {
            return -1;
        }
    }

    @Override
    public String toString() {
        return "TreeNode{" +
                "number=" + number +
                '}';
    }
}
